package chap05;

/**
 * Created by root on 2017/7/7.
 */
class LinkStack{
    private FirstLastList theList;

    public LinkStack(){
        theList = new FirstLastList();
    }

    public void push(long j){
        theList.insertFirst(j);
    }

    public long pop(){
        return theList.deleteFirst().dData;
    }

    public boolean isEmpty(){
        return theList.isEmpty();
    }

    public void displayStack() {
        System.out.print("Stack (top-->bottom): ");
        theList.displayList();
    }
}
public class LinkStackApp {
    public static void main(String[] args){
        LinkStack stack = new LinkStack();
        stack.push(20);
        stack.push(40);

        stack.displayStack();

        stack.push(60);
        stack.push(80);

        stack.displayStack();

        stack.pop();
        stack.pop();

        stack.displayStack();
    }
}
